package com.example.springbootplm.controller;

import com.example.springbootplm.pojo.Emp;
import com.example.springbootplm.pojo.PageBean;
import com.example.springbootplm.pojo.Result;
import com.example.springbootplm.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/emps")
public class EmpController {
    //分页查询
   @Autowired
    private EmpService empService;
    @GetMapping("/emps")
    public Result page(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "5")Integer pageSize){
       log.info("分页查询，参数：{},{}",page,pageSize);
       PageBean pageBean =empService.page(page,pageSize);
        return Result.success(pageBean);
    }


    //条件分页查询
 /*   @Autowired
    private EmpService empService;
    @GetMapping
    public Result page(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "5")Integer pageSize,
                       String name , Integer age,
                       @DateTimeFormat(pattern ="yyyy-MM-dd") LocalDate begin,
                       @DateTimeFormat(pattern ="yyyy-MM-dd") LocalDate end){
        log.info("分页查询，参数：{},{},{},{}",page,pageSize,name,age,begin,end);
        //调用service分页查询
        PageBean pageBean =empService.page(page,pageSize,name,age,begin,end);
        return Result.success(pageBean);
    }*/


    //删除员工
   /* @DeleteMapping("/{ids}")
    public Result delete(@PathVariable List<Integer> ids){
        log.info("批量删除操作，ids：{}",ids);
        empService.delete(ids);
        return Result.success();
    }*/


    //新增员工
   /* @PostMapping
    public Result save(@RequestBody Emp emp){
        log.info("新增员工,emp:{}",emp);
        empService.save(emp);
        return Result.success();
    }*/








































}
